package net.yla.smartbus.core.util;

import java.util.Arrays;
import java.util.Random;

/**
 * @Author : GaoMing
 * @Create_Date : 2019/11/28/15:33
 * @Pack_name : net.seocoo.smartbus.core.mapper.SendSmsUtils : SixNum
 * *****************************************************
 * 注释: 随机生成六位数字
 */
public class SixNum {

    public static String getSixNum() {
        String SixNum = "";

        Random random = new Random();
        for (int i=0;i<6;i++)
        {
            SixNum += random.nextInt(10);
        }
        return SixNum;
    }


    /**
     * 获取随机不重复字符串
     * @param d 多少个数字
     * @param range 取值范围  生成[0,10)区间的整数
     * @return
     */
    public static String getRandom(int d,int range){
        int[] num = new int[d];
        Random random = new Random();
        for (int i = 0; i < d; i++) {
            num[i] = random.nextInt(range);
            for (int j = 0; j < i; j++) {
                if (num[i]==num[j]) {
                    i--;
                    break;
                }
            }
        }
        String string = Arrays.toString(num);
        return string;
    }
}
